let mysql = require("mysql");
let con = mysql.createConnection({
    host: "127.0.0.1", 
    user: "root", 
    password: "root",
    port: "3306", 
    database: "user"
});

//创建时间
let time=new Date();
let times=time.toLocaleString();

//添加
let add="insert into user(`name`,`age`,`sex`,`creattime`,`updatetime`)values('小红','20','女','"+times+"','"+times+"')"
con.query(add,(err,data)=>{
    console.log(err)
    console.log(data)
})

//删除
let del="delete from user where name='张柳'"
con.query(del,(err,data)=>{
    console.log(err)
    console.log(data)
})

//修改
let update="update user set name='小芳',update='"+time+"' where name='小红'"
con.query(update,(err,data)=>{
    console.log(err)
    console.log(data)
})

//查询
let sel=function(page){
    let select="select * from user limit "+(6*page-6)+","+(6);
    con.query(select,(err,data)=>{
        console.log(err)
        console.log(data)
    })
}
sel(1)
con.end();